<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .active{
      color:red
    }
  </style>
</head>
<body>
  <div id = "app">
    <ul>
      <li v-for='(movie,index) in movies' :class='{active:currentIndex === index}' @click='addClass(index,$event)'>{{movie}}</li>
    </ul>
  </div>
  <script src="../js/vue.js"></script>
  <script>
    const app = new Vue({
      el:'#app',
      data:{
        message:'你好',
        movies:['海王','海尔兄弟','进击的巨人','灵笼'],
        currentIndex:0,
        // isActive:false
      },
      methods:{
        addClass(index,event){
          console.log(index)
          console.log(event)
          return this.currentIndex = index
        }
      }
    })
  </script>
</body>
</html>